package com.dindang.checkline.mvp.greendao.entity;

import com.dindang.checkline.mvp.model.entity.CheckItemEntity;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.converter.PropertyConverter;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
public class CheckPiont {
    @Id(autoincrement = true)
    private Long id;
    private int lBuilding;
    private String cNo;
    private Long lId;
    private String cName;
    private String cDesc;
    private String cQrcode;
    private String dCreate;
    private String cStatus;
    private String cPosition;
    private String userId;
    private Long lineId;
    private String isFinshPoint;
    private String rItemLastTime;
    //用到了这个Convert注解，表明它们的转换类，这样就可以转换成String保存到数据库中了
    @Convert(columnType = String.class, converter = Level_Converter.class)
    private List<CheckItem> info; //实体类中list数据


    @Generated(hash = 1168320082)
    public CheckPiont(Long id, int lBuilding, String cNo, Long lId, String cName, String cDesc,
            String cQrcode, String dCreate, String cStatus, String cPosition, String userId,
            Long lineId, String isFinshPoint, String rItemLastTime, List<CheckItem> info) {
        this.id = id;
        this.lBuilding = lBuilding;
        this.cNo = cNo;
        this.lId = lId;
        this.cName = cName;
        this.cDesc = cDesc;
        this.cQrcode = cQrcode;
        this.dCreate = dCreate;
        this.cStatus = cStatus;
        this.cPosition = cPosition;
        this.userId = userId;
        this.lineId = lineId;
        this.isFinshPoint = isFinshPoint;
        this.rItemLastTime = rItemLastTime;
        this.info = info;
    }


    @Generated(hash = 1410726426)
    public CheckPiont() {
    }


    public void setIsFinshPoint(String isFinshPoint) {
        this.isFinshPoint = isFinshPoint;
    }


    public void setrItemLastTime(String rItemLastTime) {
        this.rItemLastTime = rItemLastTime;
    }

    public String getIsFinshPoint() {
        return isFinshPoint;
    }


    public String getrItemLastTime() {
        return rItemLastTime;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setlBuilding(int lBuilding) {
        this.lBuilding = lBuilding;
    }

    public void setcNo(String cNo) {
        this.cNo = cNo;
    }

    public void setlId(Long lId) {
        this.lId = lId;
    }

    public void setcName(String cName) {
        this.cName = cName;
    }

    public void setcDesc(String cDesc) {
        this.cDesc = cDesc;
    }

    public void setcQrcode(String cQrcode) {
        this.cQrcode = cQrcode;
    }

    public void setdCreate(String dCreate) {
        this.dCreate = dCreate;
    }

    public void setcStatus(String cStatus) {
        this.cStatus = cStatus;
    }

    public void setcPosition(String cPosition) {
        this.cPosition = cPosition;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setLineId(Long lineId) {
        this.lineId = lineId;
    }

    public void setInfo(List<CheckItem> info) {
        this.info = info;
    }

    public Long getId() {
        return id;
    }

    public int getlBuilding() {
        return lBuilding;
    }

    public String getcNo() {
        return cNo;
    }

    public Long getlId() {
        return lId;
    }

    public String getcName() {
        return cName;
    }

    public String getcDesc() {
        return cDesc;
    }

    public String getcQrcode() {
        return cQrcode;
    }

    public String getdCreate() {
        return dCreate;
    }

    public String getcStatus() {
        return cStatus;
    }

    public String getcPosition() {
        return cPosition;
    }

    public String getUserId() {
        return userId;
    }

    public Long getLineId() {
        return lineId;
    }

    public List<CheckItem> getInfo() {
        return info;
    }

    public int getLBuilding() {
        return this.lBuilding;
    }

    public void setLBuilding(int lBuilding) {
        this.lBuilding = lBuilding;
    }

    public String getCNo() {
        return this.cNo;
    }

    public void setCNo(String cNo) {
        this.cNo = cNo;
    }

    public Long getLId() {
        return this.lId;
    }

    public void setLId(Long lId) {
        this.lId = lId;
    }

    public String getCName() {
        return this.cName;
    }

    public void setCName(String cName) {
        this.cName = cName;
    }

    public String getCDesc() {
        return this.cDesc;
    }

    public void setCDesc(String cDesc) {
        this.cDesc = cDesc;
    }

    public String getCQrcode() {
        return this.cQrcode;
    }

    public void setCQrcode(String cQrcode) {
        this.cQrcode = cQrcode;
    }

    public String getDCreate() {
        return this.dCreate;
    }

    public void setDCreate(String dCreate) {
        this.dCreate = dCreate;
    }

    public String getCStatus() {
        return this.cStatus;
    }

    public void setCStatus(String cStatus) {
        this.cStatus = cStatus;
    }

    public String getCPosition() {
        return this.cPosition;
    }

    public void setCPosition(String cPosition) {
        this.cPosition = cPosition;
    }

    public String getRItemLastTime() {
        return this.rItemLastTime;
    }

    public void setRItemLastTime(String rItemLastTime) {
        this.rItemLastTime = rItemLastTime;
    }

    public static class Level_Converter implements PropertyConverter<List<CheckItem>, String> {
        @Override
        public List<CheckItem> convertToEntityProperty(String databaseValue) {
            if (databaseValue == null) {
                return null;
            }
            // 先得获得这个，然后再typeToken.getType()，否则会异常
            TypeToken<List<CheckItem>> typeToken = new TypeToken<List<CheckItem>>() {
            };
            return new Gson().fromJson(databaseValue, typeToken.getType());
        }

        @Override
        public String convertToDatabaseValue(List<CheckItem> arrays) {
            if (arrays == null || arrays.size() == 0) {
                return null;
            } else {
                String sb = new Gson().toJson(arrays);
                return sb;

            }
        }
    }
}






